<?php
/**
 * Class ApiController
 */

use wepay\join\demo\common\SignUtil;
use wepay\join\demo\common\DesUtils;
use wepay\join\demo\common\ConfigUtil;
use wepay\join\demo\api\WebAsynNotificationCtrl;
use wepay\join\demo\api\WebBase;
use wepay\join\demo\api\WebSecurity;
class ApiController extends BaseController
{

	/*
	|--------------------------------------------------------------------------
	| API控制器
	|--------------------------------------------------------------------------
	|   register                    用户注册
	    login                       用户登录
	    ModifyPassword              修改密码
	    Logout                      注销用户
	    QualificationExamine        商家资质审核
	    ImproveSupplierInfo         完善商家信息
	    GetSupplierDetail           商家信息详情
	    GetIndexData                首页数据展示
	    AddLineQuery                线路查询记录
	    GetLineQueryList            线路查询历史列表


	*/

    /**
     * 参数验证
     * @param $obj
     * @param $arr
     * @author fyl
     * @date 2016-5-13
     * @return bool
     */
    public function  checkProperties($obj, $arr)
    {
        if(empty($arr)) return true;
        $obj    =   (array) $obj;

        foreach($arr as $v){
            if(empty($obj[$v])){
                return false;}
        }
        return true;
    }

    /*_________________________________________规范接口开始_______________________________________________*/

    /**
     * APP初始化
     * @author fyl
     * @date 2016-5-19
     */
    public function IndexApp(){
        try{
            $data = ApiService::instance()->GetIndexApp();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS,"获取APP信息成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }


    /**
     * 获取首页数据
     * @author fyl
     * @date 2016-5-14
     */
    public function GetIndexData()
    {
        #接收参数
        $paramObj                   =   new stdClass();
        $paramObj->page             =   empty($this->getParam('page'))?1:$this->getParam('page');  //页数
        #逻辑处理
        try{
            $data = ApiService::instance()->GetIndexData($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS,"获取首页数据成功!");
        }catch(Exception $e){

            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 用户注册
     * @author fyl
     * @data 2016-5-15
     */
    public function DeposeRegister()
    {
        #接收参数
        $paramObj                   =          new stdClass();
        $paramObj->mobile           =          $this->getParam('mobile');       //用户名
        $paramObj->password         =          $this->getParam('password');     //密码
        $paramObj->user_name        =          $this->getParam('user_name');    //姓名
        $paramObj->corporation      =          $this->getParam('corporation');  //公司名称
        $paramObj->avatar           =          $this->getParam('avatar');         //头像
        $paramObj->phone            =          $this->getParam('phone');       //手机号

        #数据结构
//        $data =
//            '{
//                "code": 1000,
//                "msg": "注册成功!",
//                "data": {}
//            }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->DeposeRegister($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "注册成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 修改用户信息
     */
    public function ModifyUserInfo(){
        #接收参数
        $paramObj                   =          new stdClass();
        $paramObj->key           =          $this->getParam('key');       //字段名
        $paramObj->val           =          $this->getParam('val');       //修改内容

        try{
            $data = ApiService::instance()->ModifyUserInfo($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "修改成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    #手机号是否已注册
    public function Mobile(){
        $paramObj                   =          new stdClass();
        $paramObj->mobile           =          $this->getParam('mobile');
        try{
            $data = ApiService::instance()->Mobile($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "允许注册");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 第三方登陆
     */
    public function ThirdLogin() 
    {
    	#收集信息
    	$paramObj                   =          new stdClass();
    	$paramObj->ch         		=          $this->getParam('ch');			//第三方名称, qq | wq
    	$paramObj->ch_id            =          $this->getParam('ch_id');		//在第三方的唯一id
    	$paramObj->user_name        =          $this->getParam('user_name');	//用户在第三方的昵称
    	$paramObj->avatar           =          $this->getParam('avatar');		//用户在第三方的头像
    	$paramObj->os_type     		=          $this->getParam('os_type');		//设备操作系统类型
    	$paramObj->model     		=          $this->getParam('model');		//设备型号
    	$paramObj->device_token     =          $this->getParam('device_token');	//设备token
    	
    	#逻辑处理
    	try{
    		$data = ApiService::instance()->ThirdLogin($paramObj);
    		return Response::json([
    				'code' => ErrorCodeEnum::STATUS_SUCCESS,
    				'msg'  => '登录成功!',
    				'data' => $data
    				]);
    	}catch(Exception $e){
    		$this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
    	}
    }

    /**
     * 用户登录
     * @author buluota
     * @data 2016-1-15
     */
    public function DeposeLogin()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->mobile           =          $this->getParam('mobile');
        $paramObj->password         =          $this->getParam('password');
/*        $paramObj->os_type          =          $this->getParam('os_type');
        $paramObj->model            =          $this->getParam('model');
        $paramObj->device_token     =          $this->getParam('device_token');*/

        #逻辑处理
        try{
            $data = ApiService::instance()->DeposeLogin($paramObj);
            return Response::json([
                'code' => ErrorCodeEnum::STATUS_SUCCESS,
                'msg'  => '登录成功!',
                'data' => $data
            ]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 获取用户信息
     * @author  buluota
     * @date 2016-1-15
     */
    public function GetUserInfo()
    {
        #逻辑处理
        try{
            $data = ApiService::instance()->GetUserInfo();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '获取个人信息成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 注销用户
     * @author  fyl
     * @date 2016-5-10
     */
    public function Logout()
    {
        #数据结构
//        $data =
//            '{
//                "code": 1000,
//                "msg": "注销成功!",
//                "data": {}
//            }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->Logout();
            return Response::json([
                'code' => ErrorCodeEnum::STATUS_SUCCESS,
                'msg'  => '注销成功!',
                'data' => $data
            ]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 商家入驻信息
     * @author fyl
     * @data 2016-5-7
     */
    public function ModifyCommonDetail()
    {
        #收集信息
        $paramObj                            =          new stdClass();
        $paramObj->supplier_id               =          $this->getParam('supplier_id');            //供应商id
        $paramObj->user_id                   =          $this->getParam('user_id');                //用户id
        $paramObj->supplier_name             =          $this->getParam('supplier_name');          //供应商名称
        $paramObj->company                   =          $this->getParam('company');                //公司名称
        $paramObj->address                   =          $this->getParam('address');                //公司所在地
        $paramObj->address_all               =          $this->getParam('address_all');            //公司详细地址
        $paramObj->phone                     =          $this->getParam('phone');                  //电话
        $paramObj->operate_license           =          $this->getParam('operate_license');        //营业执照
        $paramObj->show_img1                 =          $this->getParam('show_img1');              //商家展示图1
        $paramObj->show_img2                 =          $this->getParam('show_img2');              //商家展示图2
        $paramObj->show_img3                 =          $this->getParam('show_img3');              //商家展示图3
        #逻辑处理
        try{
            $data = ApiService::instance()->ModifyCommonDetail($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "提交完善信息成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 获取完善信息
     * @author buluota
     * @data 2016-1-15
     */
    public function GetCommonDetail()
    {
        #逻辑处理
        try{
            $data = ApiService::instance()->GetCommonDetail();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取完善信息成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 资质审核
     * @author buluota
     * @data 2016-1-15
     */
    public function ModifyCertifyInfo()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->market           =          $this->getParam('market');           //木材市场
        $paramObj->bank_account     =          $this->getParam('bank_account');     //银行账户
        $paramObj->bank_number      =          $this->getParam('bank_number');      //银行账号
        $paramObj->storage          =          $this->getParam('storage');          //仓储地
        $paramObj->id_card          =          $this->getParam('id_card');          //身份证
        $paramObj->operate_license  =          $this->getParam('operate_license');  //营业执照
        $paramObj->tax_license      =          $this->getParam('tax_license');      //税务登记

        #逻辑处理
        try{
            $data = ApiService::instance()->ModifyCertifyInfo($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "提交资质信息成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 获取资质信息
     * @author buluota
     * @data 2016-1-15
     */
    public function GetCertifyDetail()
    {
        #数据结构
//        $data =
//            '{
//                "code": 1000,
//                "msg": "提交资质信息成功!",
//                "data": {
//                    "market"            : "木材市场",
//                    "bank_account"      : "银行账户",
//                    "bank_number"       : "银行账号",
//                    "storage"           : "仓储地",
//                    "id_card"           : "身份证",
//                    "operate_license"   : "营业执照",
//                    "tax_license"       : "税务登记"
//                }
//            }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->GetCertifyDetail();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取资质信息成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 密码修改
     * @author fyl
     * @data 2016-5-13
     */
    public function ModifyPassword()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->origin_pass      =          $this->getParam('origin_pass');      //原密码
        $paramObj->new_pass         =          $this->getParam('new_pass');         //新密码
        $paramObj->confirm_pass     =          $this->getParam('confirm_pass');     //确认密码

        #逻辑处理
        try{
            $data = ApiService::instance()->ModifyPassword($paramObj);
            $this->Logout();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 重置密码
     * @author fyl
     * @data 2016-5-13
     */
    public function ResetPassword()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->mobile           =          $this->getParam('mobile');           //手机号
        $paramObj->new_pass         =          $this->getParam('new_pass');         //新密码

        #逻辑处理
        try{
            $data = ApiService::instance()->ResetPassword($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 自营商品列表
     * @author buluota
     * @data 2016-1-15
     */
    public function GetSelfSupportProduct()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->service_type     =          $this->getParam('service_type');         //自营类型  100:海外林场  101:国内原料特惠  102:木制品定制 103:成品采购
        $paramObj->page             =          $this->getParam('page', 1);             //页数

        #逻辑处理
        try{
            $data = ApiService::instance()->GetSelfSupportProduct($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取自营商品列表成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 商城商品列表
     * @author fyl
     * @data 2016-5-11
     */
    public function GetShopProduct()
    {
        #收集信息
        $paramObj                      =          new stdClass();
        $paramObj->key_word            =          $this->getParam('key_word');                //关键字
/*        $paramObj->service_type      =          $this->getParam('service_type');         //自营类型*/
        $paramObj->sort_order          =          $this->getParam('sort_order','all');        //排序条件  销量  价格
        $paramObj->page                =          $this->getParam('page', 1);                 //页数


        // $paramObj->is_self_support  =          $this->getParam('is_self_support','all');   //是否自营
        $paramObj->category            =          $this->getParam('category','all');          //分类
        $paramObj->classes             =          $this->getParam('classes','all');           //品类
        $paramObj->quality             =          $this->getParam('quality','all');           //材质
//        $paramObj->spec              =          $this->getParam('spec','all');              //规格
//        $paramObj->level             =          $this->getParam('level','all');             //等级
//        $paramObj->origin            =          $this->getParam('origin','all');            //产地
//        $paramObj->storage           =          $this->getParam('storage','all');           //仓储地
//        $paramObj->brand             =          $this->getParam('brand','all');             //品牌


        #数据结构
//        $data =
//            '{
//                "code": 1000,
//                "msg": "获取商城商品列表成功!",
//                "data": [
//                    {
//                        "product_id": 1,
//                        "product_name": "樟子松防腐木",
//                        "product_thumb":"http://api.mutouw.com/resource/upload/thumb_34a5995f0f7a8ff300c95e9ad3bba4b8.jpeg",
//                        "level": 1,
//                        "spec": "260*110*12",
//                        "place": "美国",
//                        "stock": "500",
//                        "price": "1500"
//                    }
//                    {
//                        "product_id": 2,
//                        "product_name": "进口樟子松",
//                        "product_thumb":"http://api.mutouw.com/resource/upload/thumb_3daa2bcbf52c3866d31af9fe5a6e8b7b.jpeg",
//                        "level": 1,
//                        "spec": "200*110*10",
//                        "place": "俄罗斯",
//                        "stock": "3060",
//                        "price": "1480"
//                    }
//                    {
//                        "product_id": 3,
//                        "product_name": "优质软木",
//                        "product_thumb":"http://api.mutouw.com/resource/upload/thumb_863df10aff53c15a45aa7cf394e5df4f.jpeg",
//                        "level": 1,
//                        "spec": "200*110*10",
//                        "place": "俄罗斯",
//                        "stock": "9856",
//                        "price": "3"
//                    }
//                    {
//                        "product_id": 4,
//                        "product_name": "天然水曲柳木皮",
//                        "product_thumb":"http://api.mutouw.com/resource/upload/thumb_87db6520078e9c726978db9ccf767e4c.jpeg",
//                        "level": 1,
//                        "spec": "180*90*10",
//                        "place": "浙江德清",
//                        "stock": "69850",
//                        "price": "5.50"
//                    }
//                    {
//                        "product_id": 5,
//                        "product_name": "黄金檀原木",
//                        "product_thumb":"http://api.mutouw.com/resource/upload/thumb_e0cd7c98e238427b576fd53bb1769f11.jpeg",
//                        "level": 1,
//                        "spec": "180*90*10",
//                        "place": "墨西哥",
//                        "stock": "2658",
//                        "price": "10000"
//                    }
//                ]
//            }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->GetShopProduct($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }


    /**
     * 添加商品
     * @author buluota
     * @data 2016-1-15
     */
    public function AddProduct()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->product_id     =          $this->getParam('product_id');              //产品ID
        $paramObj->product_name     =          $this->getParam('product_name');          //产品名称
        $paramObj->category         =          $this->getParam('category');              //分类
        $paramObj->classes          =          $this->getParam('classes');               //品类
       /* $paramObj->quality          =          $this->getParam('quality');               //材质*/
        $paramObj->spec             =          $this->getParam('spec');                  //规格
        $paramObj->place            =          $this->getParam('place');                 //产地
        $paramObj->storage          =          $this->getParam('storage');               //仓储地
     /*   $paramObj->level            =          $this->getParam('level');                 //等级
        $paramObj->brand_id         =          $this->getParam('brand_id');              //品牌*/
        $paramObj->stock            =          $this->getParam('stock');                 //库存量
        $paramObj->contact          =          $this->getParam('contact');               //联系方式
        $paramObj->contact_name     =          $this->getParam('contact_name');               //联系方式
        $paramObj->start_num        =          $this->getParam('start_num');             //起订量
        $paramObj->product_img      =          $this->getParam('product_img');           //商品图片
        $paramObj->price            =          $this->getParam('price');                 //商品价格
        /*$paramObj->unit             =          $this->getParam('unit');                  //单位*/
        $paramObj->show_img1        =          $this->getParam('show_img1');            //展示图1
        $paramObj->show_img2        =          $this->getParam('show_img2');            //展示图2
        $paramObj->description      =          $this->getParam('description');             //商品描述

        #逻辑处理
        try{
            $data = ApiService::instance()->AddProduct($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "产品添加/修改成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 产品分类信息
     * @author fyl
     * @date 2016-5-7
     */
    public function GetCategories()
    {
        try{
            $data = ApiService::instance()->GetCategories();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取添加产品信息成功");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 获取产品信息
     * @author buluota
     * @data 2016-1-15
     */
    public function GetProductDetail()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->product_id       =          $this->getParam('product_id');            //商品ID

//        #数据结构
//        $data =
//            '{
//                "code": 1000,
//                "msg": "获取商品信息成功!",
//                "data": {
//                    "show_pic1": "http://api.mutouw.com/resource/upload/fe4aa4821d933c09db0034436ce4373c.png",
//                    "show_pic2": "http://api.mutouw.com/resource/upload/fe4aa4821d933c09db0034436ce4373c.png",
//                    "show_pic3": "http://api.mutouw.com/resource/upload/183e39f0b81ebe9e6e7f32e8042e6c7c.png",
//                    "product_name": "缅甸柚木",
//                    "spec": "口径30公分以上",
//                    "storage": "上海",
//                    "place": "缅甸",
//                    "level": "一级",
//                    "stock": "200吨",
//                    "start_num": "1吨",
//                    "quality": "柚木",
//                    "cate_info": "品类介绍",
//                    "supplier_info": "商家介绍",
//                    "comments": [
//                        {
//                            "avator": "http://img5.duitang.com/uploads/item/201406/26/20140626190424_TCXuP.jpeg",
//                            "supplier_name": "吴彦祖",
//                            "content": "柚木做行道树，很不错！"
//                        }
//                        {
//                            "avator": "http://img4.duitang.com/uploads/item/201512/30/20151230114015_5aziQ.thumb.224_0.jpeg",
//                            "supplier_name": "阡陌",
//                            "content": "缅甸柚木，很不错！"
//                        }
//                        {
//                            "avator": "http://img5.duitang.com/uploads/item/201509/18/20150918204730_EBXrP.png",
//                            "supplier_name": "莫言",
//                            "content": "柚木对化学有较强的腐蚀性！"
//                        }
//                        {
//                            "avator": "http://img4.duitang.com/uploads/item/201505/15/20150515225424_iGrv4.jpeg",
//                            "supplier_name": "雪儿",
//                            "content": "柚木是热带树种，要求较高的温度。"
//                        }
//                        {
//                            "avator": "http://cdn.duitang.com/uploads/item/201406/24/20140624163257_ccJvw.jpeg",
//                            "supplier_name": "赛罗拉",
//                            "content": "柚木是制造高档家具地板、室内外装饰的好材料。"
//                        }
//                    ]
//                }
//            }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->GetProductDetail($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取产品信息成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

 /*   public function AddSupplier()
    {
        #接收参数
        $paramObj                            =          new stdClass();
        $paramObj->user_id                   =          $this->getParam('user_id');                //用户id
        $paramObj->supplier_name             =          $this->getParam('supplier_name');          //供应商名称
        $paramObj->company                   =          $this->getParam('company');                //公司名称
        $paramObj->address                   =          $this->getParam('address');                //公司所在地
        $paramObj->address_all               =          $this->getParam('address_all');            //公司详细地址
        $paramObj->phone                     =          $this->getParam('phone');                  //电话
        $paramObj->operate_license           =          $this->getParam('operate_license');        //营业执照
        $paramObj->show_img1                  =          $this->getParam('show_img1');              //商家展示图1
        $paramObj->show_img2                  =          $this->getParam('show_img2');              //商家展示图2
        $paramObj->show_img3                  =          $this->getParam('show_img3');              //商家展示图3

        #数据结构
//        $data =
//            '{
//                "code": 1000,
//                "msg": "注册成功!",
//                "data": {}
//            }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->AddSupplier($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "注册成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }*/

    /**
     *产品上下架列表
     * @author alice
     * @date 2016-2-16
     */
    public function GetManageProduct()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->op               =          $this->getParam('op');       //操作类型 上架 1 下架 0
        $paramObj->status           =          $this->getParam('status');   //操作类型  2
        $paramObj->page             =          $this->getParam('page');     //分页

        #逻辑处理
        try{
            $data = ApiService::instance()->GetManageProduct($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '获取产品成功');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 产品上下架
     * @author fyl
     * @data 2016-5-10
     */
    public function ManageProduct()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->product_id       =          $this->getParam('product_id');            //商品ID
        $paramObj->op               =          $this->getParam('op');                    //操作类型 上架up  下架down
        #逻辑处理
        try{
            $data = ApiService::instance()->ManageProduct($paramObj);
            $msg = $paramObj->op?"上架成功":"下架成功";
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $msg);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 商家详情
     * @author buluota
     * @data 2016-1-15
     */
    public function GetSupplierDetail()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->supplier_id      =          $this->getParam('supplier_id');            //商家ID
        $paramObj->page             =          $this->getParam('page',1);

        #数据结构
//        $data =
//            '{
//                "code": 1000,
//                "msg": "获取商家信息成功!",
//                "data": {
//                    "show_pic1": "/resource/upload/fe4aa4821d933c09db0034436ce4373c.png",
//                    "show_pic2": "/resource/upload/fe4aa4821d933c09db0034436ce4373c.png",
//                    "show_pic3": "/resource/upload/183e39f0b81ebe9e6e7f32e8042e6c7c.png",
//                    "supplier_name": "东莞市博森木业",
//                    "brand_name": "品牌名称",
//                    "storage": "仓储地",
//                    "market": "木材市场",
//                    "business_scope": "经营范围",
//                    "scale": "规模",
//                    "product_list": [
//                        {
//                            "product_id": 1,
//                            "product_thumb": "/resource/upload/3f7a248da0dfc7edeecb0dcf2a1c17f3.jpg",
//                            "product_name": "柚木木皮",
//                            "spec": "260*110*12",
//                            "level": "锯材",
//                            "place": "缅甸",
//                            "price": "1500"
//                        }
//                        {
//                            "product_id": 2,
//                            "product_thumb": "/resource/upload/e0cd7c98e238427b576fd53bb1769f11.jpg",
//                            "product_name": "锯材",
//                            "spec": "260*110*12",
//                            "level": "I",
//                            "place": "俄罗斯",
//                            "price": "5500"
//                        }
//                        {
//                            "product_id": 3,
//                            "product_thumb": "/resource/upload/f71b38e3e0b465fd4300a6cf554ab800.jpg",
//                            "product_name": "非洲进口烘干板材",
//                            "spec": "180*110*12",
//                            "level": "I",
//                            "place": "非洲加蓬",
//                            "price": "5500"
//                        }
//                        {
//                            "product_id": 4,
//                            "product_thumb": "/resource/upload/d35ef913b9551387838a819b1b5136a9.jpg",
//                            "product_name": "国产木板材",
//                            "spec": "170*110*12",
//                            "level": "I",
//                            "place": "河南",
//                            "price": "1600"
//                        }
//                        {
//                            "product_id": 5,
//                            "product_thumb": "/resource/upload/9651c3512e5eb6e5db12bd545b7dc037.jpg",
//                            "product_name": "杉木",
//                            "spec": "200*110*12",
//                            "level": "I",
//                            "place": "河南",
//                            "price": "980"
//                        }
//                    ]
//                }
//            }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->GetSupplierDetail($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取商家信息成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());}
    }

    /**
     * 增加/修改收货地址
     * @author fyl
     * @data 2016-5-9
     */
    public function ModifyAddress()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->address_id       =          $this->getParam('address_id');               //收货地址id
        $paramObj->address_all      =          $this->getParam('address_all');              //收货地区
        $paramObj->consignee        =          $this->getParam('consignee');                //收货人
        $paramObj->mobile           =          $this->getParam('mobile');                   //联系方式
        $paramObj->address          =          $this->getParam('address');                  //详细地址
        #逻辑处理
        try{
            $data = ApiService::instance()->ModifyAddress($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '地址修改成功！');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     *修改默认收获地址
     */
    public function ModifyIsDefault()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->address_id       =          $this->getParam('address_id');               //收货地址id
        #逻辑处理
        try{
            $data = ApiService::instance()->ModifyIsDefault($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '默认地址修改成功！');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 删除收货地址
     * @author buluota
     * @data 2016-1-15
     */
    public function DeleteAddress()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->address_id       =          $this->getParam('address_id');               //地址ID
        $paramObj->is_default       =          $this->getParam('is_default');               //是否默认地址

        #逻辑处理
        try{
            $data = ApiService::instance()->DeleteAddress($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '删除成功！');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 获取收货地址列表
     * @author fyl
     * @data 2016-5-12
     */
    public function GetAddressList()
    {
        #逻辑处理
        try{
            $data = ApiService::instance()->GetAddressList();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 消息中心
     * @author buluota
     * @data 2016-1-15
     */
    public function GetNoticeList()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->is_read          =          $this->getParam('is_read','all');                         //消息类型
        $paramObj->page             =          $this->getParam('page', 1);                               //分页

        #逻辑处理
        try{
            $data = ApiService::instance()->GetNoticeList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '获取消息列表成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 消息内容
     *
     */
    public function GetNoticeDetail()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->notice_id            =          $this->getParam('notice_id');                     //消息ID

        #逻辑处理
        try{
            $data = ApiService::instance()->GetNoticeDetail($paramObj);
            return $this->view('webview.webview_notice')->with('notice', $data);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 删除消息
     * @author buluota
     * @data 2016-1-15
     */
    public function DeleteNotice()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->notice_id        =          $this->getParam('notice_id');                     //消息ID

        #数据结构
//        $data = '{
//                    "code": 1000,
//                    "msg": "收货地址操作成功!",
//                    "data": {}
//                }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->DeleteNotice($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '删除消息成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 线路查询
     * @author buluota
     * @data 2016-1-15
     */
    public function QueryLine()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->departure        =          $this->getParam('departure');                      //出发地
        $paramObj->destination      =          $this->getParam('destination');                    //目的地
        $paramObj->spec_time        =          $this->getParam('spec_time');                      //出发时间

        #逻辑操作
        try{
            $data = ApiService::instance()->QueryLine($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "路线查询成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 发布询价单
     * @author buluota
     * @data 2016-1-15
     */
    public function PublishInquiry()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->product_name         =          $this->getParam('product_name');                       //品名
        $paramObj->spec                 =          $this->getParam('spec');                               //规格
        $paramObj->number               =          $this->getParam('number');                             //求购量
        $paramObj->contact              =          $this->getParam('contact');                            //联系人
        $paramObj->mobile               =          $this->getParam('mobile');                             //联系方式
        $paramObj->description          =          $this->getParam('description');                        //求购描述

        #逻辑操作
        try{
            $data = ApiService::instance()->PublishInquiry($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "询价单发布成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 发布供货单
     * @author buluota
     * @data  2016-1-15
     */
    public function PublishSupply()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->product_name         =          $this->getParam('product_name');                       //品名
        $paramObj->spec                 =          $this->getParam('spec');                               //规格
        $paramObj->price                =          $this->getParam('price');                              //价格
        $paramObj->stock                =          $this->getParam('stock');                              //库存
        $paramObj->place                =          $this->getParam('place');                              //产地
        $paramObj->storage              =          $this->getParam('storage');                            //仓储地
        $paramObj->contact              =          $this->getParam('contact');                            //联系人
        $paramObj->mobile               =          $this->getParam('mobile');                             //联系方式

        #数据结构
//        $data = '{
//                    "code": 1000,
//                    "msg": "供货单发布成功!",
//                    "data": {}
//                }';
//        return $data;

        #逻辑操作
        try{
            $data = ApiService::instance()->PublishSupply($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '供货单发布成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 发布定制单
     * @author fyl
     * @data  2016-5-11
     */
    public function PublishCustomize()
    {
        #收集信息
        $paramObj                       =          new stdClass();
     /*   $paramObj->product_name         =          $this->getParam('product_name');                       //品名
        $paramObj->spec                 =          $this->getParam('spec');                               //规格
        $paramObj->number               =          $this->getParam('number');                             //求购量*/
        $paramObj->contact              =          $this->getParam('contact');                            //联系人
        $paramObj->mobile               =          $this->getParam('mobile');                             //联系方式
        $paramObj->description          =          $this->getParam('description');                        //定制需求


        #逻辑操作
        try{
            $data = ApiService::instance()->PublishCustomize($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '定制单发布成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 获取询价单列表
     * @author buluota
     * @data 2016-1-15
     */
    public function GetInquiryList()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->is_self              =          $this->getParam('is_self');                          //是否个人
        $paramObj->page                 =          $this->getParam('page',1);                          //分页

        #逻辑操作
       try{
            $data = ApiService::instance()->GetInquiryList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取询价单列表成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 获取供货单列表
     * @author buluota
     * @data 2016-1-15
     */
    public function GetSupplyList()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->is_self              =          $this->getParam('is_self');                          //是否我的供货单
        $paramObj->page                 =          $this->getParam('page',1);                             //分页

        #逻辑操作
        try{
            $data = ApiService::instance()->GetSupplyList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取供货单列表成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 获取定制单列表
     * @author buluota
     * @data 2016-1-15
     */
    public function GetCustomizeList()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->is_self              =          $this->getParam('is_self');     //是否我的定制单
        $paramObj->page                 =          $this->getParam('page',1);      //页数

        #逻辑操作
        try{
            $data = ApiService::instance()->GetCustomizeList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '获取定制单成功');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 木业圈动态
     * @author buluota
     * @data 2016-1-15
     */
    public function GetCircleList()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->is_self              =          $this->getParam('is_self');                          //是否我的动态  1是  0否
        $paramObj->page                 =          $this->getParam('page',1);

        #逻辑操作
        try{
            $data = ApiService::instance()->GetCircleList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取木业圈动态成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 获取资讯列表
     * @author buluota
     * @data 2016-1-15
     */
    public function GetInformationList()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->cate                 =          $this->getParam('cate', 'all');    //资讯类型  全部(all) 头条(top_line) 文化(culture)  专题(subject)  动态(trends)
        $paramObj->page                 =          $this->getParam('page', 1);

        #逻辑处理
        try{
            $data = ApiService::instance()->GetInformationList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取资讯列表成功");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 获取资讯详情
     * @author buluota
     * @data 2016-1-15
     */
    public function GetInformationDetail()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->news_id              =          $this->getParam('news_id');                          //资讯ID

        #逻辑处理
        try{
            $info = ApiService::instance()->GetInformationDetail($paramObj);
            return $this->view('webview.webview_information')->with('info',$info);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 发布木业圈动态
     * @author buluota
     * @data 2016-1-15
     */
    public function PublishCircle()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->content              =           $this->getParam('content');
        $paramObj->show_img1            =           $this->getParam('show_img1');
        $paramObj->show_img2            =           $this->getParam('show_img2');
        $paramObj->show_img3            =           $this->getParam('show_img3');
        $paramObj->show_img4            =           $this->getParam('show_img4');
        $paramObj->show_img5            =           $this->getParam('show_img5');
        $paramObj->show_img6            =           $this->getParam('show_img6');
        $paramObj->show_img7            =           $this->getParam('show_img7');
        $paramObj->show_img8            =           $this->getParam('show_img8');
        $paramObj->show_img9            =           $this->getParam('show_img9');


        #逻辑处理
        try{
            $data = ApiService::instance()->PublishCircle($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "发布木业圈动态成功!");
        }catch(Exception $e){
            $this->rest->error('发布木业圈失败!', ErrorCodeEnum::STATUS_ERROR,new stdClass());
        }
    }

    /**
     * 获取上传图片token
     */
    public function GetToken()
    {
       #逻辑处理
        try{
//            $data               =   new stdClass();
            $data =   QiniuUpload::instance()->generateToken();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取token成功");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 反馈列表
     * @author buluota
     * @data 2016-1-15
     */
    public function GetFeedbackList()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->page                 =          $this->getParam('page', 1);

        #逻辑处理
        try{
            $data = ApiService::instance()->GetFeedbackList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '获取反馈列表成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 发送反馈
     * @author buluota
     * @date 2016-03-03
     */
    public function SendFeedback()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->content              =           $this->getParam('content');
        $paramObj->mobile               =           $this->getParam('mobile');

        #逻辑处理
        try{
            $data = ApiService::instance()->SendFeedback($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '发送反馈成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 收藏产品
     * @author buluota
     * @data 2016-1-15
     */
    public function CollectProduct()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->product_id           =          $this->getParam('product_id');
        $paramObj->op                   =          $this->getParam('op');       //操作类型   1：加入收藏  0：取消收藏

        #逻辑处理
        try{
            $data = ApiService::instance()->CollectProduct($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "操作成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 我的收藏
     * @author buluota
     * @data 2016-1-15
     */
    public function GetCollectList()
    {
        #收集信息
        $paramObj                       =          new stdClass();
        $paramObj->page                 =          $this->getParam('page',1);

        #逻辑处理
        try{
            $data = ApiService::instance()->GetCollectList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 林场列表
     * @author buluota
     * @data 2016-1-15
     */
    public function GetForestList()
    {
        #逻辑处理
        try{
            $data = ApiService::instance()->GetForestList();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取林场服务成功!");
        }catch(Exception $e){
           $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 林场详情
     * @author buluota
     * @data 2016-1-15
     */
    public function ForestDetail()
    {

        #收集信息
        $paramObj                  =   new stdClass();
        $paramObj->forest_id       =   $this->getParam('forest_id');

//        #数据结构
//        $data = '{
//                    "code": 1000,
//                    "msg": "获取林场详情成功!",
//                    "data": {
//                        "forest_id": 1,
//                        "forest_name": "巴拉圭林场",
//                        "country_name": "巴拉圭",
//                        "category": "原木、锯木、名贵硬木、集成材、人造板",
//                        "show_pic1": "",
//                        "show_pic2": "",
//                        "show_pic3": "",
//                        "video_id": 1,
//                        "description": "巴拉圭林场资源储量丰富，SPF是其中最大的一个树种群，就森林储量来讲，
//                                        SPF约占大约170亿立方米，在卑诗省和阿尔伯特省就有约55亿立方米，
//                                        是所有加拿大树种里森林储量最大的商用软木树种。加拿大生产的SPF锯材质量轻、稳定性强、
//                                        易于加工、纹理漂亮，且供应量充足，使之成为建筑及结构用材的不二选择。"
//                    }
//                }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->ForestDetail($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取林场详情成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 林场需求
     * @author buluota
     * @data 2016-1-15
//     */
    public function ForestNeed()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->forest_id         =   $this->getParam('forest_id');
        $paramObj->product_name      =   $this->getParam('product_name');
        $paramObj->number            =   $this->getParam('number');
        $paramObj->spec              =   $this->getParam('spec');
        $paramObj->contact           =   $this->getParam('contact');
        $paramObj->mobile            =   $this->getParam('mobile');
        $paramObj->supplier_name     =   $this->getParam('supplier_name');

        #逻辑处理
        try{
            $data = ApiService::instance()->ForestNeed($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "发布林场需求成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 港口分布
     * @author buluota
     * @data 2016-1-15
     */
    public function GetHarbourList()
    {
        #收集信息（无）

        #数据结构
//        $data = '{
//                    "code": 1000,
//                    "msg": "获取港口分布成功!",
//                    "data": {
//                        "hot_harbour": [
//                            {
//                                "harbour_id": 1,
//                                "harbour_name": "大连港口",
//                                "harbour_img": "http://gtb.baidu.com/HttpService/get?p=dHlwZT1pbWFnZS9qcGVnJm49dmlzJnQ9YWRpbWdfdGImYz10YjppZyZyPTk0MjIwNjA4MywxMzU2MDgzMTgz"
//                            },
//                            {
//                                "harbour_id": 2,
//                                "harbour_name": "厦门港口",
//                                "harbour_img": "http://img1.imgtn.bdimg.com/it/u=543994750,3627818145&fm=21&gp=0.jpg"
//                            },
//                            {
//                                "harbour_id": 3,
//                                "harbour_name": "福州港口",
//                                "harbour_img": "http://img0.imgtn.bdimg.com/it/u=1358101389,2493274953&fm=21&gp=0.jpg"
//                            }
//                        ],
//                        "harbour_list": [
//                            {
//                                "harbour_id": 1,
//                                "harbour_name": "天津港口",
//                                "harbour_img": "http://img1.imgtn.bdimg.com/it/u=3770041362,1207889321&fm=21&gp=0.jpg"
//                            },
//                            {
//                                "harbour_id": 2,
//                                "harbour_name": "武汉港口",
//                                "harbour_img": "http://img5.imgtn.bdimg.com/it/u=3619114417,3391120712&fm=21&gp=0.jpg"
//                            },
//                            {
//                                "harbour_id": 3,
//                                "harbour_name": "辽宁港口",
//                                "harbour_img": "http://img0.imgtn.bdimg.com/it/u=1358101389,2493274953&fm=21&gp=0.jpg"
//                            },
//                            {
//                                "harbour_id": 4,
//                                "harbour_name": "大连港口",
//                                "harbour_img": "http://img5.imgtn.bdimg.com/it/u=238825648,321780445&fm=21&gp=0.jpg"
//                            },
//                            {
//                                "harbour_id": 5,
//                                "harbour_name": "厦门港口",
//                                "harbour_img": "http://img1.imgtn.bdimg.com/it/u=543994750,3627818145&fm=21&gp=0.jpg"
//                            },
//                            {
//                                "harbour_id": 6,
//                                "harbour_name": "福州港口",
//                                "harbour_img": "http://img0.imgtn.bdimg.com/it/u=1358101389,2493274953&fm=21&gp=0.jpg"
//                            }
//                        ]
//                    }
//                }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->GetHarbourList();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取港口分布成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 港口详情
     * @author buluota
     * @data 2016-1-15
     */
    public function HarbourDetail()
    {
        #收集信息
        $paramObj                  =   new stdClass();
        $paramObj->harbour_id      =   $this->getParam('harbour_id');

        try{
            $data = ApiService::instance()->HarbourDetail($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取港口详情成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 港口需求
     * @author buluota
     * @data 2016-1-15
     */
    public function HarbourNeed()
    {
        #收集信息
        $paramObj = new stdClass();
        $paramObj->harbour_id        =   $this->getParam('harbour_id');
        $paramObj->product_name      =   $this->getParam('product_name');
        $paramObj->number            =   $this->getParam('number');
        $paramObj->spec              =   $this->getParam('spec');
        $paramObj->expire_time       =   $this->getParam('expire_time');
        $paramObj->certificate       =   $this->getParam('certificate');
        $paramObj->introduce         =   $this->getParam('introduce');
        $paramObj->contact           =   $this->getParam('contact');
        $paramObj->mobile            =   $this->getParam('mobile');

        #逻辑处理
        try{
            $data = ApiService::instance()->HarbourNeed($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "发布港口需求成功");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 运输需求
     * @author buluota
     * @data 2016-1-15
     */
    public function TransportNeed()
    {
        #获取参数
        $paramObj                       =       new stdClass();
        $paramObj->product_name         =       $this->getParam('product_name');
        $paramObj->spec                 =       $this->getParam('spec');
        $paramObj->number               =       $this->getParam('number');
        $paramObj->model_type           =       $this->getParam('model_type');
        $paramObj->describe             =       $this->getParam('describe');
        $paramObj->contacts             =       $this->getParam('contacts');
        $paramObj->mobile               =       $this->getParam('mobile');

        #数据结构
        $data = '{
                    "code": 1000,
                    "msg": "发布运输需求成功!",
                    "data": {}
                }';
        return $data;

        #逻辑处理
//        try{
//            $data = ApiService::instance()->TransportNeed($paramObj);
//            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
//        }catch(Exception $e){
//            $this->rest->error($e->getMessage(), $e->getCode());
//        }

    }

    /**
     * 仓储列表
     * @author buluota
     * @data 2016-1-15
     */
    public function GetStorageList()
    {
        #收集信息
        $paramObj                       =       new stdClass();
        $paramObj->type                 =       $this->getParam('type');   //0-国外，1-国内

        #逻辑处理
        try{
            $data = ApiService::instance()->GetStorageList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS,"仓储列表获取成功");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 仓储详情
     * @author buluota
     * @data 2016-1-15
     */
    public function StorageDetail()
    {
        #收集信息
        $paramObj                  =   new stdClass();
        $paramObj->storage_id      =   $this->getParam('storage_id');

        #逻辑处理
        try{
            $data = ApiService::instance()->StorageDetail($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取仓储详情成功!");
        }catch(Exception $e){
           $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 仓库需求
     * @author buluota
     * @data 2016-1-15
     */
    public function StorageNeed()
    {
        #收集信息
        $paramObj                       =   new stdClass();
        $paramObj->storage_id           =   $this->getParam('storage_id');      //仓库ID
        $paramObj->product_name         =   $this->getParam('product_name');    //货品
        $paramObj->spec                 =   $this->getParam('spec');            //规格
        $paramObj->number               =   $this->getParam('number');          //数量
        $paramObj->start_time           =   $this->getParam('start_time');      //开始时间
        $paramObj->end_time             =   $this->getParam('end_time');        //结束时间
        $paramObj->introduce            =   $this->getParam('introduce');       //描述
        $paramObj->contact              =   $this->getParam('contact');         //联系人
        $paramObj->mobile               =   $this->getParam('mobile');          //联系方式

        #数据结构
//        $data = '{
//                    "code": 1000,
//                    "msg": "发布仓储需求成功!",
//                    "data": {}
//                }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->StorageNeed($paramObj);
           $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "发布仓储需求成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }
    /**
         * 买（卖）家全部订单（待付款，待收货，已完成）
     * @author liuyuchao
     * @data 2016-05-07
     */
    public function OrderAll()
    {
        //如果是买家，则supplier传值必须为0  ， 如果是卖家，则user_id传值必须为零
        #收集信息
        $user_id           =   $this->getParam('user_id');      //用户ID
        $supplier_id           =   $this->getParam('supplier_id');      //供应商ID
        $status           =   $this->getParam('status');      //订单状态（买家：0,全部,1，待付款，2，待发货，3，待收货）（卖家：0，全部，1，待付款，2，待发货，3，已发货）
        $page           =   $this->getParam('page');
        try{
            $data = ApiService::instance()->GetOrderAll($user_id ,$supplier_id,$status,$page);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取订单信息成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }

    }

    /**
     * 帮助中心
     * @author buluota
     * @data 2016-1-15
     */
    public function HelpCenter()
    {
        #逻辑处理
        try{
            $data = ApiService::instance()->HelpCenter();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 帮助文章
     * @author buluota
     * @data 2016-1-15
     */
    public function HelpArticle()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->help_id           =   $this->getParam('help_id');

        #逻辑处理
        try{
            $data = ApiService::instance()->HelpArticle($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '获取帮助文章成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 关于木投
     * @author buluota
     * @data 2016-1-15
     */
    public function About()
    {
        #收集信息（无）

        #数据结构
//        $data = '{
//                    "code": 1000,
//                    "msg": "获取关于木投成功!",
//                    "data": {
//                    "article_id":10,
//                    "title":"关于木投",
//                    "content":"目前木材供应链存在以下问题：环节过多、成本过高、效率低下、无行业标准、产品尺寸不一、品种不透明、产能过剩、
//                                供大于求、恶性竞争，这些问题，导致客户无法明明白白地消费。　　根据行业的特性，去掉中间环节，制定行业标准，
//                                提高效率，同样的产品以低于市场的价格，线上销售。从海外的林场资源到运输、批发、生产加工、销售，到物流、人流、
//                                资金流、信息流，全环节打通，形成一个完整的产业链与生态圈。"
//                    }
//                }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->About();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '获取关于木投成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 订单详情
     * @author 刘玉超
     * @data 2016-05-12
     */
    public function OrderDetail()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->order_id          =   $this->getParam('order_id');

        #逻辑处理
        try{
            $data = ApiService::instance()->OrderDetail($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取订单详情成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 订单状态
     * @author buluota
     * @data 2016-1-15
     */
    public function OrderStatus()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->order_id          =   $this->getParam('order_id');

//        #数据结构
//        $data = '{
//                    "code": 1000,
//                    "msg": "获取订单状态成功!",
//                    "data": {
//                        "order_id": 1,
//                        "order_sn": "mt11897732918",
//                        "status": [
//                            {
//                                "update_event": "您提交了订单，等待系统确定。",
//                                "update_time": "2015-12-02 9:30"
//                            },
//                            {
//                                "update_event": "提货",
//                                "update_time": "2015-12-02 10:30"
//                            },
//                            {
//                                "update_event": "从郑州发往濮阳",
//                                "update_time": "2015-12-02 10:30"
//                            },
//                            {
//                                "update_event": "您的货物已分拣到收货站",
//                                "update_time": "2015-12-02 10:30"
//                            },
//                            {
//                                "update_event": "由派送员李景瑞派件",
//                                "update_time": "2015-12-02 10:30"
//                            }
//                        ]
//                    }
//                }';
//        return $data;

        #逻辑处理
        try{
        $data = ApiService::instance()->OrderStatus($paramObj);
        $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
    }catch(Exception $e){
        $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
    }
    }

    /**
     * 订单列表
     * @author buluota
     * @data 2016-1-17
     */
    public function OrderList()
    {
        #收集信息
        $paramObj                    =   new stdClass();
//        $paramObj->keywords          =   $this->getParam('keywords');       //关键词
//        $paramObj->type              =   $this->getParam('period');         //筛选类型
        $paramObj->page              =   $this->getParam('page');            //分页

        #数据结构
//        $data = '{
//                    "code": 1000,
//                    "msg": "获取订单成功!",
//                    "data": {
//                        "condition": {
//                            "keywords": "柏木",
//                            "period": 1
//                        },
//                        "order_list": [
//                            {
//                                "order_id": 1,
//                                "order_sn": "mt198912121111",
//                                "order_time": "2015-12-12",
//                                "shipping_event": "商家已确认订单",
//                                "order_status": 1,
//                                "amount": "¥5000",
//                                "product_list": [
//                                    {
//                                        "product_id": 11,
//                                        "product_name": "洪都拉斯香柏木",
//                                        "product_thumb": "http://img3.imgtn.bdimg.com/it/u=564518969,3926499620&fm=206&gp=0.jpg",
//                                        "spec": "3.5cm"
//                                    }
//                                ]
//                                "order_id": 2,
//                                "order_sn": "mt12431213311",
//                                "order_time": "2015-12-15",
//                                "shipping_event": "商家已确认订单",
//                                "order_status": 1,
//                                "order_status": 1,
//                                "amount": "¥8000",
//                                "product_list": [
//                                    {
//                                        "product_id": 13,
//                                        "product_name": "进口樟子松",
//                                        "product_thumb": "http://pic.58pic.com/58pic/11/88/18/67y58PICdHz.jpg",
//                                        "spec": "3.5cm"
//                                    }
//                                ]
//                                "order_id": 3,
//                                "order_sn": "mt12er3er3311",
//                                "order_time": "2015-12-15",
//                                "shipping_event": "商家已确认订单",
//                                "order_status": 1,
//                                "order_status": 1,
//                                "amount": "¥12000",
//                                "product_list": [
//                                    {
//                                        "product_id": 14,
//                                        "product_name": "黄金檀原木",
//                                        "product_thumb": "http://static16.photo.sina.com.cn/bmiddle/500eab23t6be6a5d22aef&690",
//                                        "spec": "3.5cm"
//                                    }
//                                ]
//                            }
//                        ]
//                    }
//                }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->OrderList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取订单成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }



    /**
     * 删除订单
     * @author buluota
     * @data 2016-1-17
     */
    public function DeleteOrder()
    {
        #收集信息
       // $paramObj                    =   new stdClass();
        $order_id          =   $this->getParam('order_id');

        #逻辑处理
        try{
            $data = ApiService::instance()->DeleteOrder($order_id);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 购物车添加商品
     * @author fyl
     * @data 2016-5-09
     */
    public function AddCart()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->product_id        =   $this->getParam('product_id');

        #逻辑处理
        try{
        $data = ApiService::instance()->AddCart($paramObj);
        $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '添加购物车成功!');
    }catch(Exception $e){
        $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
    }
    }

    /**
     * 购物车更新商品
     * @author fyl
     * @data 2016-5-12
     */
    public function UpdateCart()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->product_id        =   $this->getParam('product_id');
        $paramObj->product_num       =   $this->getParam('product_num');

        #逻辑处理
        try{
            $data = ApiService::instance()->UpdateCart($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '更新购物车成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 发票列表
     * @author buluota
     * @data 2016-09-10
     */
    public function GetInvoiceList()
    {
        $invoice        =      ApiService::instance()->GetInvoiceList();
        $this->rest->success($invoice, ErrorCodeEnum::STATUS_SUCCESS, '获取发票类型成功!');
    }

    /**
     * 购物车列表
     * @author fyl
     * @data 2016-09-10
     */
    public function CartInfo()
    {
        #收集信息
        $paramObj              =   new stdClass();
        $paramObj->page        =   $this->getParam('page',1);
        #逻辑处理
        try{
            $data = ApiService::instance()->CartList($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '获取购物车列表成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 购物车删除商品
     * @author fyl
     * @data 2016-5-9
     */
    public function DeleteCart()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->cart_id        =   $this->getParam('cart_id');
        #逻辑处理
        try{
            $data = ApiService::instance()->DeleteCart($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '购物车删除产品成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 提交订单
     * @author fyl
     * @data 2016-05-12
     */
    public function SubmitOrder()
    {
        #逻辑处理
        try{
            $data = ApiService::instance()->SubmitOrder();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '提交订单成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 视频播放
     * @author buluota
     * @data 2016-1-17
     */
    public function VideoPlay()
    {
        #收集信息
        $paramObj                       =   new stdClass();
        $paramObj->type_id              =   $this->getParam('type_id');
        $paramObj->video_id             =   $this->getParam('video_id');

        #数据结构 webview

        #逻辑处理
        try{
            $video = ApiService::instance()->VideoPlayUrl($paramObj);
            return $this->view('webview.webview_video')->with('video_url',$video->video_url);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 确认订单
     * @author fyl
     * @data 2016-5-9
     */
    public function ConfirmOrder()
    {
        $paramObj                       =   new stdClass();
        $paramObj->cart_id             =   $this->getParam('cart_id');
        #逻辑处理
        try{
            $data = ApiService::instance()->ConfirmOrder($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '确认订单成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 生成订单
     * @author fyl
     * @date 2016-5-12
     */
    public function GenerateOrder()
    {
        #收集信息
        $paramObj                      =   new stdClass();
        $paramObj->address_id          =   $this->getParam('address_id');
        $paramObj->cart_id             =   $this->getParam('cart_id');

        #逻辑处理
        try{
            $data =  ApiService::instance()->GenerateOrder($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, '订单生成成功!');
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 支付配送
     * @author buluota
     * @data 2016-1-17
     */
    public function PayShipping()
    {
        #收集信息（无）

        #数据结构
//        $data = '{
//                    "code": 1000,
//                    "msg": "获取支付配送信息成功!",
//                    "data": {
//                        "pay_list": [
//                            {
//                                "pay_id": 1,
//                                "pay_name": "京东支付"
//                            },
//                            {
//                                "pay_id": 2,
//                                "pay_name": "货到付款"
//                            }
//                        ],
//                        "shipping_list": [
//                            {
//                                "shipping_id": 1,
//                                "shipping_name": "商家配送"
//                            },
//                            {
//                                "shipping_id": 2,
//                                "shipping_name": "平台配送"
//                            }
//                        ]
//                    }
//                }';
//        return $data;

        #逻辑处理
        try{
            $data = ApiService::instance()->PayShipping();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取支付配送信息成功");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 木业圈  点赞/取消
     * @author buluota
     * @data 2016-1-17
     */
    public function AddCircleLike()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->circle_id         =   $this->getParam('circle_id');          //动态ID
        $paramObj->user_id           =   $this->getParam('user_id');            //点赞用户ID
        $paramObj->is_like           =   $this->getParam('is_like');            //是否点赞  1是  0否

        #逻辑处理
        try{
            $data = ApiService::instance()->AddCircleLike($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "木业圈点赞成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 木业圈评论
     * @author buluota
     * @data 2016-1-17
     */
    public function AddCircleComment()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->circle_id         =   $this->getParam('circle_id');          //动态ID
        $paramObj->content           =   $this->getParam('content');            //评论内容
        $paramObj->user_id           =   $this->getParam('user_id');            //用户ID

        #逻辑处理
        try{
            $data = ApiService::instance()->AddCircleComment($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 回复木业圈需求单
     * @author buluota
     * @data 2016-1-17
     */
    public function ReplyCircleRequest()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->reply_id          =   $this->getParam('reply_id');
        $paramObj->type              =   $this->getParam('type');               //1:询价单 2:供货单 3:定制单
        $paramObj->company           =   $this->getParam('company');            //公司
        $paramObj->contact           =   $this->getParam('contact');             //联系人
        $paramObj->mobile            =   $this->getParam('mobile');              //联系方式
        $paramObj->price             =   $this->getParam('price');               //报价
        $paramObj->number            =   $this->getParam('number');              //采购量

       #逻辑处理
           try{
                $data = ApiService::instance()->ReplyCircleRequest($paramObj);
                $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "木业圈需求单回复成功!");
            }catch(Exception $e){
                $this->rest->error($e->getMessage(), $e->getCode());
           }
    }

    /**
     * 资金需求页面
     * @author  alice
     * @date 2016-1-23
     */
    public function CashFlow()
    {
        return $this->view('webview.webview_banking');
    }

    /**
     * 获取资金需求页面
     * @author  alice
     * @date 2016-1-23
     * @return string
     */
    public function GetCashFlow()
    {
        $data = '{
                    "code": 1000,
                    "msg": "操作成功!",
                    "data": {
                        "title":"资金需求",
                        "url":"http://api.mutouw.com/Api/cash_flow"
                        }
                }';
        return $data;
    }

    /**
     * 商家统计页面
     * @return mixed
     * @author alice
     * @date 2016-2-16
     */
    public function SupplierStatistics()
    {
        return $this->view('webview.webview_business');
    }

    /**
     * 获取商家统计
     * @author  alice
     * @date 2016-1-23
     * @return string
     */
    public function GetSupplierStatistics()
    {
        $data = '{
                    "code": 1000,
                    "msg": "操作成功!",
                    "data": {
                        "title":"商家统计",
                        "url":"http://api.mutouw.com/Api/supplier_statistics"
                        }
                }';
        return $data;
    }


    //新增库存商品
    public function AddStoreProduct()
    {
        #收集信息
        $paramObj                          =     new stdClass();
        $paramObj->product_name            =     $this->getParam('product_name');
        $paramObj->category                =     $this->getParam('category');
        $paramObj->classes                 =     $this->getParam('classes');
        $paramObj->quality                 =     $this->getParam('quality');
        $paramObj->spec                    =     $this->getParam('spec');
        $paramObj->place                   =     $this->getParam('place');
        $paramObj->storage                 =     $this->getParam('storage');
        $paramObj->level                   =     $this->getParam('level');
        $paramObj->brand_id                =     $this->getParam('brand_id');
        $paramObj->stock                   =     $this->getParam('stock');
        $paramObj->start_num               =     $this->getParam('start_num');
        $paramObj->goods_thumb             =     $this->getParam('goods_thumb');
        $paramObj->goods_img1              =     $this->getParam('goods_img1');
        $paramObj->goods_img2              =     $this->getParam('goods_img2');
        $paramObj->introduce               =     $this->getParam('introduce');

        #逻辑处理
        try{
            $data = ApiService::instance()->AddStoreProduct($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "新增成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }


    //编辑库存商品
    public function EditStoreProduct()
    {
        #收集信息
        $paramObj                          =     new stdClass();
        $paramObj->product_id              =     $this->getParam('product_id');
        $paramObj->product_name            =     $this->getParam('product_name');
        $paramObj->product_sn              =     $this->getParam('product_sn');
        $paramObj->brand_id                =     $this->getParam('brand_id');
        $paramObj->cate_id                 =     $this->getParam('cate_id');
        $paramObj->channel                 =     $this->getParam('channel');
        $paramObj->stock                   =     $this->getParam('stock');
        $paramObj->shop_price              =     $this->getParam('shop_price');
        $paramObj->description             =     $this->getParam('description');
        $paramObj->supplier                =     $this->getParam('supplier');
        $paramObj->place                   =     $this->getParam('place');
        $paramObj->spec                    =     $this->getParam('spec');
        $paramObj->level                   =     $this->getParam('level');
        $paramObj->storage                 =     $this->getParam('storage');
        $paramObj->start_num               =     $this->getParam('start_num');
        $paramObj->is_self_support         =     $this->getParam('is_self_support');
        $paramObj->is_index                =     $this->getParam('is_index');
        $paramObj->is_up                   =     $this->getParam('is_up');
        $paramObj->goods_img               =     $this->getParam('goods_img');

        #逻辑处理
        try{
            $data = GoodsService::instance()->EditGoods($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "编辑成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    //删除库存商品
    public function DeleteStoreProduct()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->product_id        =   $this->getParam('product_id');         //商品ID

        #逻辑处理
        try{
            $data = ApiService::instance()->DeleteStoreProduct($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "删除成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    //新增商品评论
    public function AddProductComment()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->product_id        =   $this->getParam('product_id');         //商品ID
        $paramObj->content           =   $this->getParam('content');            //评论内容
        $paramObj->is_anonymous      =   $this->getParam('is_anonymous');       //是否匿名
        $paramObj->order_id          =   $this->getParam('order_id');           //订单id
        $paramObj->rank              =   $this->getParam('rank');               //星级

        #逻辑处理
        try{
            $data = ApiService::instance()->AddProductComment($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "评论成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    #上传头像
    public function UploadAvatar()
    {
        #收集信息
        $paramObj                    =   new stdClass();
        $paramObj->avatar            =   $this->getParam('avatar');         //头像

        #逻辑处理
        try{
            $data = ApiService::instance()->UploadAvatar($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "上传头像成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    public function JdPay()
    {
        $config = Config::get("jd_pay");
        $successCallbackUrl = $config["successCallbackUrl"];
        $failCallbackUrl = $config["failCallbackUrl"];
        $merchantNum = $config["merchantNum"];
        $notifyUrl = $config["notifyUrl"];
//        $amount=$_GET['amount'];
//        $trade_num=$_GET['trade_num'];
//        $order_time=$_GET['order_time'];
        $param                          =       [];
        $param['currency']              =      "CNY";//货币类型
        $param['merchantNum']           =       $merchantNum;//商户号
        $param['merchantRemark']        =       "木投网 —— 木材全产业链服务平台";//商户备注信息
        $param['failCallbackUrl']       =      $failCallbackUrl;//失败跳转地址
        $param['notifyUrl']             =      $notifyUrl;
        $param['successCallbackUrl']    =      $successCallbackUrl;
        //$param['tradeAmount']           =    $_SESSION['array']['amount']*100;//订单金额
        $param['tradeAmount']           =   1;//订单金额
        $param['tradeDescription']      =       "交易描述";//订单描述
        $param['tradeName']             =       "交易名称";//订单标题
        $param['tradeNum']              =       $_SESSION['array']['trade_num'];//交易流水号
        $param['tradeTime']             =       date('Y-m-d H:i:s',$_SESSION['array']['order_time']); //订单时间
        $param['version']               =       "3.0";
        $param['token']                 =       "";

        $specialJson = array();
        $specialJson["specBankCardNo"]  =  '';
        $specialJson["specIdCard"]      = $_GET['specIdCard'];
        $specialJson["specName"]        =  $_GET['specName'];

        $param["specifyInfoJson"]       = json_encode($specialJson);

        $sign = SignUtil::sign($param);
        $param["merchantSign"] = $sign;
        //敏感信息加密
        $_SESSION['tradeAmount'] = $param["tradeAmount"];
        $_SESSION['tradeName'] = $param["tradeName"];
        //获取商户 DESkey
        //对敏感信息进行 DES加密
        $desUtils  = new DesUtils();
//      $config = Config::get("jd_pay");
        $key = $config["desKey"];
        $param["merchantRemark"]    =   $desUtils->encrypt($param["merchantRemark"],$key);
        $param["tradeNum"]          =   $desUtils->encrypt($param["tradeNum"],$key);
        $param["tradeName"]         =   $desUtils->encrypt($param["tradeName"],$key);
        $param["tradeDescription"]  =   $desUtils->encrypt($param["tradeDescription"],$key);
        $param["tradeTime"]         =   $desUtils->encrypt($param["tradeTime"],$key);
        $param["tradeAmount"]       =   $desUtils->encrypt($param["tradeAmount"],$key);
        $param["currency"]          =   $desUtils->encrypt($param["currency"],$key);
        $param["notifyUrl"]         =   $desUtils->encrypt($param["notifyUrl"],$key);
        $param["successCallbackUrl"] =  $desUtils->encrypt($param["successCallbackUrl"],$key);
        $param["failCallbackUrl"]    =  $desUtils->encrypt($param["failCallbackUrl"],$key);
        $param["specifyInfoJson"]    =  $desUtils->encrypt($param["specifyInfoJson"],$key);
        $_SESSION['tradeInfo'] = $param;



        return Redirect::to('/Api/pay_submit_test');
    }

    public function PaySubmit()
    {
        $config = Config::get("jd_pay");
        $serverPayUrl = $config["serverPayUrl"];
        return $this->view('webview.pay_submit')->with(['serverPayUrl' => $serverPayUrl]);


    }
    public function PayFirst()
    {

        $order_id=$_GET['order_id'];
        $data = ApiService::instance()->SelectOrder($order_id);
        $_SESSION['array'] = $data;
       // $config = Config::get("jd_pay");
       // $serverPayUrl = $config["serverPayUrl"];
        return $this->view('webview.pay_first');


    }
    public function SuccessUrl()
    {
        $tradeNum=$_GET['tradeNum'];

        //echo $tradeNum;
        // ApiService::instance()->UpdateStatus($tradeNum);
            $config = Config::get("jd_pay");
        // $serverPayUrl = $config["serverPayUrl"];
        return $this->view('webview.success_url');


    }
    public function FailUrl()
    {
        // $config = Config::get("jd_pay");
        // $serverPayUrl = $config["serverPayUrl"];
        return $this->view('webview.fail_url');


    }
    public function PaySubmitTest()
    {
        $config = Config::get("jd_pay");
        $serverPayUrl = $config["serverPayUrl"];
        //return $this->view('webview.pay_submit_test');
        return $this->view('webview.pay_submit_test')->with(['serverPayUrl' => $serverPayUrl]);
    }
    /**
     * 取消订单
     * @author lyc
     * @data 2016-1-17
     */
    public function CancelOrder()
    {
        #收集信息
        //  $paramObj                    =   new stdClass();
        $order_id       =   $_GET['order_id'];

        #逻辑处理
        try{
            $data = ApiService::instance()->CancelOrder($order_id);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }
    //确认收货
    public function ConfirmReceipt(){
        $order_id       =   $_GET['order_id'];

        #逻辑处理
        try{
            $data = ApiService::instance()->ConfirmReceipt($order_id);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }
    //修改价格
    public function ChangePrice(){
        $order_id       =   $_GET['order_id'];
        $amount        =   $_GET['amount'];
        #逻辑处理
        try{
            $data = ApiService::instance()->ChangePrice($order_id,$amount);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }


    }
    //确认发货
    public function SendGoods(){
        $order_id       =   $_GET['order_id'];
        #逻辑处理
        try{
            $data = ApiService::instance()->SendGoods($order_id);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }
    //异步通知
    public function Notify(){
        $MD5_KEY="zQmMsDHKkJnbfpwaoyjqmdqrsbOrMloB";
        $DES_KEY="nZFFhbWP8ftPhrUNlyAT0MLsW9/0iR/j";
        $w = new WebAsynNotificationCtrl();
        $data = $w->execute ($MD5_KEY,$DES_KEY,$this->getParam('resp') );
        //print_r($data);
        $xml = simplexml_load_string($data); //创建 SimpleXML对象
        $data = json_decode(json_encode($xml),TRUE);
        $tradeNum = $data['TRADE']['ID'];
        if($data['RETURN']['CODE']==0000){
            ApiService::instance()->UpdateStatus($tradeNum);
            $response= "success";

        }else{
            ApiService::instance()->UpdateTradeNum($tradeNum);
            $response= "success";
        }
    return $response;

    }
   //意见反馈
    public function Opinion(){
        $content = $this->getParam('content');
        $phone = $this->getParam('phone');
        #逻辑处理
        try{
            $data = ApiService::instance()->Opinion($content,$phone);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, $this->error_msg[ProfessionErrorCodeEnum::STATUS_SUCCESS]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode());
        }
    }
    //异步通知
    public function Pos(){

        $key="9999999999999999"; //该key由双方定义
        $command = $this->getParam('Command');
        $data = $this->getParam('Data');
        $sign = $this->getParam('Sign');
        $response="";
        $checkmd5 = md5($data.$key);
        $aeshelper = new WebSecurity();
        if($sign==$checkmd5){

            $apihelper = new WebSecurity();
            $notbase64data = $aeshelper->decrypt($key,$key,$data);
            switch ($command) {
                case "0100":
                    $response = ApiService::instance()->poslogin(trim($notbase64data));
                    break;
                case "0101":
                    $response = ApiService::instance()->posloginout(trim($notbase64data));
                    break;
//              case "0102":
//                  $response = ApiService::instance()->posgetOrder(trim($notbase64data));
//                    break;
//                case "0103":
//                    $response = ApiService::instance()->posreport(trim($notbase64data));
//                    break;
//                case "0106":
//                    $response = ApiService::instance()->posgetOrderlist(trim($notbase64data));
//                    break;
                default:
                    $response= "{\"Response\":\"01\",\"Message\":\"没有该命令字\"}";
            }

        }else{
            $response= "{\"Response\":\"01\",\"Message\":\"md5验证失败\"}";
        }
        $response=json_encode($response);
       return $aeshelper->encrypt($key,$key,$response);
    }
    /*____________________________________________规范接口结束______________________________________________________*/

}
